<template>
  <div class="shou">
    <div class="top">
        <h3>吃了吗</h3>
        <input type="text" placeholder="请输入商家、商品名称"  @click="$router.push('/sousuo')">
    </div>
    <!-- 轮播图 -->
    <van-swipe class="my-swipe" :autoplay="3000" indicator-color="white">
        <van-swipe-item v-for="(item,index) in bannerlist" :key="index"><img :src="item.bannerUrl" alt=""></van-swipe-item>
        
    </van-swipe>
    <!-- 排序 -->
    <div class="paixue">
        <div v-for="(item,index) in paixu" :key="index" >{{item}}</div>
    </div>
    <div class="goods">
        <div class="list" v-for="(item,index) in shop" :key="index" @click="toDetail(item)">
        <div class="imgbox">
            <img :src="item.picUrl" alt="">
        </div>
        <div class="text">
            <h4>{{item.name}}</h4>
            <span>{{item.monthSalesTip}}</span><br>
            <span>评分：{{item.wmPoiScore}}</span>
            <span>距离：{{item.distance}}</span>
        </div>
    </div>
    </div>
    
    <router-view></router-view>
  </div>
</template>

<script>
import {shop_list,tuan_list,user_login,banner_list} from '../utils/api'
export default {
    data() {
        return {
            paixu:['综合排序','距离最近',"销量最高",'筛选'],
            shop:[],
            bannerlist:[],
        }
    },
    mounted() { //组件挂载生命周期函数
    //在组件中 只需要调用封装好的函数 就可以发起ajax请求
    // 请求 店铺列表
    shop_list().then((res)=>{
    //   console.log(res.data);
      this.shop=res.data.list;
    //   console.log(this.shop);
    }),
    banner_list().then((res)=>{
        this.bannerlist=res.data.list;

    })
    },
  methods: {
    toDetail(item){//点击商品跳转到详情页
        // console.log("跳");
        this.$router.push('/xianqingye/'+item.mtWmPoiId);
    },
    sousuo(){
        this.$router.push('/sousuo');
        console.log('跳')
    }
  },
}
</script>

<style scoped>
.shou{
    position: absolute;
    width: 100%;
    height: 100%;
}
.top{
    /* width: 100%; */
    /* padding: 10px; */
    background-color: lightskyblue;
}
.top>input{
    width: 100%;
    text-align: center;
    border-radius: 10px;
    height: 30px;
    margin-bottom:10px ;
}
.lubo{
    /* width: 100%; */
    padding: 10px;
}
.lubo>img{
    width: 100%;
    height: 80px;
    border-radius: 10px;
    border: none;
    background-color: aqua; 
}
.paixue{
    display: flex;
    justify-content: space-around;
    padding: 10px 0;
}
.goods{
    padding-bottom: 20px;
}
.list{
    display: flex;
    padding: 10px;
}
.list:nth-last-child(1){
    margin-bottom: 40px;
}
.list>.imgbox{
    width: 100px;
    background-color: aqua;
    margin-right:10px ;
}
.list>.imgbox>img{
    width: 100%;
}
.my-swipe .van-swipe-item {
    color: #fff;
    font-size: 20px;
    line-height: 100px;
    text-align: center;
    background-color: #39a9ed;
  }
  .my-swipe .img{
    width: 100%;
  }
</style>